package com.agile.leetcode.autocloeable;

/**
 * 实现autoclose接口，自动统计耗时，流的自动关闭也是因为实现该接口
 *
 * @Author:ChenZhangKun
 * @Date: 2021/11/15 10:23
 */
public class Cost implements AutoCloseable {
    private Long currentTime;

    public Cost(Long currentTime) {
        this.currentTime = currentTime;
    }

    @Override
    public void close() throws Exception {
        // 输出耗时
        System.out.println(System.currentTimeMillis() - currentTime);
    }
}
